package com.yunhe.rentcars.pro.service.system.impl;

import com.yunhe.rentcars.commons.dto.TreeNode;
import com.yunhe.rentcars.pro.dao.system.SysDictDao;
import com.yunhe.rentcars.pro.entity.permi.Permission;
import com.yunhe.rentcars.pro.entity.system.SysDict;
import com.yunhe.rentcars.pro.service.system.SysDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SysDictServiceImpl implements SysDictService {
    @Autowired
    private SysDictDao sysDictDao;
    @Override
    public void save(SysDict sysDict) {
        sysDictDao.save(sysDict);

    }

    @Override
    public void update(SysDict sysDict) {
        sysDictDao.update(sysDict);

    }

    @Override
    public List<SysDict> findList() {
        return sysDictDao.findList();
    }

    @Override
    public List<TreeNode> findTreeNodes(SysDict sysDict) {
        List<TreeNode> treeNodes = new ArrayList<>();
        List<SysDict> allContent = sysDictDao.findList();
        if(allContent!= null){
            for(SysDict ac:allContent){
                TreeNode treeNode = new TreeNode(ac.getId(),ac.getFid(),ac.getName());
                treeNodes.add(treeNode);
            }
        }
        return treeNodes;
    }
}
